const express = require('express');
const app = express();
const config = require('./config');
const router = require('./router/index');
app.all('*', function(req, res, next) {
	res.header('Access-Control-Allow-Origin', req.get('origin'));
	res.header('Access-Control-Allow-Credentials', true);
	res.header('Access-Control-Allow-Headers', 'Content-Type,Content-Length, Authorization, Accept,X-Requested-With');
	res.header('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS');
	res.header('X-Powered-By', ' 3.2.1');
	if (req.method == 'OPTIONS') res.status(200).send();
	else next();
});
router(app);
app.listen(config.port, () => {
	console.log(`server running http://localhost:${config.port}`);
});
